//
// Created by DengLibin on 2019/1/1 0001.
//

//
// Created by DengLibin on 2019/1/1 0001.
//

//
// Created by DengLibin on 2018/12/31 0031.
//

//
// Created by DengLibin on 2018/12/29 0029.
//

#include <wx/app.h>
#include <wx/wx.h>
#include <wx/wxprec.h>
#include <string>
#include <wx/dcbuffer.h>
using namespace std;
/**
 *表格布局
 */
class Demo7Frame : public wxFrame
{
private:
    //声明事件表
wxDECLARE_EVENT_TABLE();


public:
    Demo7Frame(string & title):wxFrame(nullptr, wxID_ANY, title)
    {
        initPosition();
        initPanel();
    }

    void initPanel(){
        //创建一个顶层网格布局控件
        wxGridSizer * gridSizer = new wxGridSizer(4, 3, 0, 0); // 4行3列
        this->SetSizer(gridSizer);
        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 3; j++){
                wxString s ="button_";
                s<<i<<"_"<<j;
                wxButton * button = new wxButton(this, wxID_ANY,s);
                gridSizer->Add(button, 0, wxALIGN_CENTER_HORIZONTAL, 5);
            }
        }
    }

    void initPosition(){
        //设置窗口位置
        wxPoint position;
        position.x = 300;
        position.y = 300;
        SetPosition(position);
        //设置背景色
        wxColour backGroundColor(0,100,0);
        SetBackgroundColour(backGroundColor);
        //设置宽高
        this->m_minWidth = 800;
        this->m_minHeight = 600;
    }

};


class Demo7App:public wxApp
{
    bool OnInit()
    {
        string title = "Demo7";
        //  wxFrame * frame = new wxFrame(NULL, wxID_ANY, "第一个窗体");
        Demo7Frame * frame = new Demo7Frame(title);
        frame->Show();
        return true;
    }
};
//事件和函数绑定
wxBEGIN_EVENT_TABLE(Demo7Frame, wxFrame)
wxEND_EVENT_TABLE()

// 有了这一行就可以使用 OurApp& wxGetApp了()
DECLARE_APP(Demo7App)
//告诉主应用程序是哪个类wxWidgets（启动）
//IMPLEMENT_APP(Demo7App)
